package com.bbva.gptf.back.dominio;

import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.bbva.jee.arq.spring.core.log.I18nLog;
import com.bbva.jee.arq.spring.core.log.I18nLogFactory;

@Component
@Configurable
public class SpBorrarDatos {
	
	private static final I18nLog LOG = I18nLogFactory.getLogI18n(SpBorrarDatos.class);

    
	private SimpleJdbcCall simpleJdbcCall;
    private DataSource dataSource;

    @Autowired
    public void setDataSource(DataSource dataSource) {
          this.dataSource = dataSource;
    }

    @PersistenceContext
    transient EntityManager entityManager;
	
    @Transactional
	public void execute(int cdProceso){
    	String procedureName = "PKG_GPT.SP_BORRAR_DATOS";
        this.simpleJdbcCall = new SimpleJdbcCall(this.dataSource);
        this.simpleJdbcCall.withoutProcedureColumnMetaDataAccess();
        this.simpleJdbcCall.withProcedureName(procedureName);
        this.simpleJdbcCall.declareParameters(new SqlParameter("P_CD_PROCESO", Types.NUMERIC));
        Map<String, Object> parametros = new HashMap<String, Object>();
        parametros.put("P_CD_PROCESO", cdProceso);
        this.simpleJdbcCall.execute(parametros);
        
    	
	}
}
